package com.yulinlin.starter;

import com.yulinlin.jdbc.mysql.MysqlWrapperManager;
import com.yulinlin.jdbc.serialize.impl.*;
import com.yulinlin.jdbc.session.SqlSession;
import com.yulinlin.jdbc.session.SqlTemplate;
import com.yulinlin.lang.util.SpringUtil;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

@Configurable
public class YulinlinConfiger {
    @Bean
    public LongSerialize LongSerialize(){
        return new LongSerialize();
    }

    @Bean
    public EnumSerialize EnumSerialize(){
        return new EnumSerialize();
    }


    @Bean
    public ListSerialize ListJsonSerialize(){
        return new ListSerialize();
    }

    @Bean
    public ListStringSerialize ListStringSerialize(){
        return new ListStringSerialize();
    }

    @Bean
    public DateSerialize DateSerialize(){
        return new DateSerialize();
    }

    @Bean
    public MapSerialize MapJsonSerialize(){
        return new MapSerialize();
    }


    @Bean
    public SpringUtil SpringUtil(){
        return new SpringUtil();
    }

    @Bean
    public MysqlWrapperManager WrapperManager(){
        return new MysqlWrapperManager();
    }


    @Bean
    public SqlTemplate SqlTemplate(JdbcTemplate jdbcTemplate, List<ITypeSerialize> iTypeSerializeList){
        SqlTemplate sqlTemplate =  new SqlTemplate(jdbcTemplate);
        sqlTemplate.registerTypeSerialize(iTypeSerializeList);
        return sqlTemplate;
    }

    @Bean
    public SqlSession SqlSession(SqlTemplate sqlTemplate,MysqlWrapperManager wrapperManager){
        SqlSession sqlSession =  new SqlSession(sqlTemplate,wrapperManager);
        return sqlSession;
    }


}
